/** 
 * @file animation.h
 * @Synopsis  classes fro animation
 * @author Kumar Anik
 * @version 1.0
 * @date 2010-06-25
 */
#include "figures.h"
#include <vector>
#include <sstream>
#include <string>

using namespace std;

/** 
 * @Synopsis  class for moion of a group along a path
 */
class AnimateMotion {
	stringstream sout;
public:
	AnimateMotion()
	{
		dur = 5;
		fill = "freeze";
		repeatCount="indefinite";
	}

	string path;
	int dur;
	string repeatCount;
	string fill;

	string draw();
};


/** 
 * @Synopsis  Basic Animation Class
 */
class Animation {
private:
	vector <string> components;
	bool pathDefined;
	stringstream s;
public:
	Animation() {
		s << "\n<g> \n";
	}
	
	void add(string s);
	string draw();
};

/** 
 * @Synopsis  draws the animation of the group along a path
 * 
 * @Returns  the SVG animation code
 */
string AnimateMotion::draw()
{
	sout << "\n<animateMotion path=\""<< path << "\" fill=\"" << fill;
	sout << "\" dur=\"" << dur << "s\" repeatCount=\"" << repeatCount;
	sout << "\" />";
	
	return sout.str();
}

/** 
 * @Synopsis  to add a component (figure / animation property) to the current animation
 * 
 * @Param s SVG code of the component
 */
void Animation::add(string s) {
	components.push_back(s);
	
}

/** 
 * @Synopsis  draws the animation
 * 
 * @Returns   SVG code for the animation
 */
string Animation::draw() 
{
	int i = 0;
	for( ; i < components.size(); i++ ) {
		s << components[i];
	}

	s<<"\n</g>\n";

	return s.str();
}



